package com.ug.managent.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;


import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ug.common.annotation.Log;
import com.ug.common.core.controller.BaseController;
import com.ug.common.core.domain.AjaxResult;
import com.ug.common.enums.BusinessType;
import com.ug.managent.domain.Cover;
import com.ug.managent.service.ICoverService;
import com.ug.common.utils.poi.ExcelUtil;
import com.ug.common.core.page.TableDataInfo;

/**
 * 井盖档案Controller
 * 
 * @author Leo
 * @date 2025-04-22
 */
@RestController
@RequestMapping("/managent/cover")
public class CoverController extends BaseController
{
    @Autowired
    private ICoverService coverService;



    /**
     * 查询井盖档案列表
     */
    @PreAuthorize("@ss.hasPermi('managent:cover:list')")
    @GetMapping("/list")
    public TableDataInfo list(Cover cover)
    {
        startPage();
        List<Cover> list = coverService.selectCoverList(cover);
        return getDataTable(list);
    }

    /**
     * 导出井盖档案列表
     */
    @PreAuthorize("@ss.hasPermi('managent:cover:export')")
    @Log(title = "井盖档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Cover cover)
    {
        List<Cover> list = coverService.selectCoverList(cover);
        ExcelUtil<Cover> util = new ExcelUtil<Cover>(Cover.class);
        util.exportExcel(response, list, "井盖档案数据");
    }

    /**
     * 获取井盖档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('managent:cover:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(coverService.selectCoverById(id));
    }


    /**
     * 新增井盖档案
     */
    @PreAuthorize("@ss.hasPermi('managent:cover:add')")
    @Log(title = "井盖档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Cover cover)
    {
        return toAjax(coverService.insertCover(cover));
    }

    /**
     * 修改井盖档案
     */
    @PreAuthorize("@ss.hasPermi('managent:cover:edit')")
    @Log(title = "井盖档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Cover cover)
    {
        return toAjax(coverService.updateCover(cover));
    }

    /**
     * 删除井盖档案
     */
    @PreAuthorize("@ss.hasPermi('managent:cover:remove')")
    @Log(title = "井盖档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(coverService.deleteCoverByIds(ids));
    }
}
